package sg.org.scs.splashawards.biz;

import sg.org.scs.splashawards.dao.TeamDAO;
import sg.org.scs.splashawards.dto.Participation;
import sg.org.scs.splashawards.dto.Team;
import sg.org.scs.splashawards.exceptions.DAOException;
import sg.org.scs.splashawards.exceptions.DataFormatException;
import sg.org.scs.splashawards.exceptions.DuplicationException;

public class TeamService {

	private TeamDAO teamDAO;
	
	public TeamService() {
		teamDAO = new TeamDAO();
	}


	public void createTeam(Team team) throws DAOException,DataFormatException,DuplicationException{
		teamDAO.insertTeam(team);
	}
	
	public Team getTeam(int teamId)throws DAOException,DataFormatException,DuplicationException{
		return teamDAO.getTeam(teamId);
	}
	
	private boolean validate(Team team) throws DataFormatException,DuplicationException, DAOException{
		if(teamDAO.getTeam(team.getTeamName()) == null)
		    return true;
		else {
			throw new DuplicationException("Please supply a different team name");
		}
		
	}
}
